package com.pzc.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.luojun.entity.Commodity;
import com.luojun.entity.User;
import com.luojun.service.UCommodityService;
import com.pzc.entity.PersonManage;
import com.pzc.service.PersonManageService;

/**
 * Servlet implementation class DoAdd
 */
@WebServlet("/DoUpdate")
public class DoUpdate extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DoUpdate() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		HttpSession session = request.getSession();
		
		
		User u = (User)session.getAttribute("user");
		
		String nickname = request.getParameter("nickname");
		String birthday = request.getParameter("birthday");
		String gender = request.getParameter("gender");
		String address = request.getParameter("address");
		
		PersonManage pm =new PersonManage();
		session.setAttribute("nickname", nickname);
		pm.setUserid(u.getUserId());
        pm.setNickname(nickname);
        pm.setBirthday(birthday);
        pm.setAddress(address);
        pm.setGender(gender);
        
        System.out.println(pm);
		PersonManageService pms = new PersonManageService();
		
         pms.updateManage(pm);
		
		request.getRequestDispatcher("ToPersonalCenter").forward(request, response);
		
//		UCommodityService ucs = new UCommodityService();
//		Commodity commodity = ucs.findByCommodityId(id);
//		ucs.update(commodity);
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
	}

}
